<?php
	class procControl extends Control{
		function index(){
			$db=M('pro');
			$row=$db->select();
			$count=$db->count();
    		$page=new page($count,8);
    		$row=$db->order('paddtime desc')->findall($page->limit());
    		$this->assign('row',$row);
    		$this->assign('page',$page->show(2));
			$this->display();
		}
		function addshow(){
			$db=M('category');
	 		$sql="select cid,cname,pid,concat(path,'_',cid)as p from com_category order by p";
			$category=$db->query($sql);
			foreach($category as $k=>$v){
				$count=count(explode("_",$v['p']))-2;
				$category[$k]['html']=str_repeat("-", $count*2);
			}
			$this->assign('category',$category);
			$this->display();
		}
		function add(){
			$db=M('pro');
			$upload=new upload();
			$upFile=$upload->upload();
			$_POST['pimg']=$upFile[0]['path'];
			$_POST['paddtime']=time();
			if($db->add()){
				$this->success("添加成功",'index');
			}else{
				$this->success("添加失败");
			}
		}
	}
?>